<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.anhry.app.safety.util.Util"%>
<%@ include file="/WEB-INF/pages/share/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>企业列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=basePath+Util.SKIN%>/css/right.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<%=basePath%>/js/jquery-1.7.2.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/dbdialog/lhgdialog.min.js<%=Util.LHGDIALOG%>"></script>
	<script type="text/javascript" src="<%=basePath%>/js/oa.js"></script>
	<script type="text/javascript" src="<%=path%>/js/selected.js"></script>
	<script type="text/javascript">
	/**/
		var api = frameElement.api, W = api.opener;
		
		$(function() {
		
		
			//setSelectedValue(); 
			setSelectedUser();
			//用户级别change事件
			//全选
			$("#all").click(function() { $('[name=ids]:checkbox').attr('checked', true); });
			//清空
			$("#empty").click(function() { 
			
				//$('[name=ids]:checkbox').attr('checked', false); 
				
				$('[name=ids]:checkbox').each(function() { 
				if($(this).attr('disabled')==null){
						this.checked = false;
					}
				});
			});
			//反选
			$("#rev").click(function() {
						$('[name=ids]:checkbox').each(function() { this.checked = !this.checked;});
			});
			
			//选择按钮
			$("#select").click(function() {
				var selected = false;
				$('[name=ids]:checkbox').each(function() {
					    if(this.checked) {
					    	selected = true; return false;
					    }
				});
			  if(!selected)	{
			  	msgDialog('请选择收件人!', 'hits.png')
			 	//dialogWithParent(W, '请选择收件人!', api, 'hits.png');
			  } else {//赋值到父窗口
			  		var addresseeIds = W.document.getElementById("addcorp");
    				var addressNames = W.document.getElementById("corpspan");
    				
    				//选中的用户ID和名字
    				var selectedUserIds="", selectUserNames="";
    				$('[name=ids]:checkbox:checked').each(function() {
    				
    				//alert($(this).attr('disabled'));
    					if($(this).attr('disabled')==null){
	    					var userId = $(this).val();
	    					selectedUserIds += userId+ ",";
	    					selectUserNames += "<span id='c"+userId+"'>"+$("#" + userId).val() +
	    							"<img src='<%=basePath%>/images/delete.gif'  name='img' onclick=javascript:deleteChooseCorp('"
	    							+userId+"');>;&nbsp;</span>";
	    					$(this).attr('disabled',true);
			   				$(this).attr('checked',true);
			   			}
    				});
    				selectedUserIds = selectedUserIds.substr(0, selectedUserIds.length-1);
    				
    				//赋值到发送邮件窗口页面
    				if(addresseeIds.value && addresseeIds.value.length > 0 ) {
    					addresseeIds.value += "," + selectedUserIds;
    					addressNames.innerHTML += selectUserNames;
    				} else {
    					addresseeIds.value =  selectedUserIds;
    					addressNames.innerHTML = selectUserNames;
    				}
    				msgDialog('添加收件人成功!', 'succ.png')
    				//dialogWithParent(W, '添加收件人成功!', api, 'succ.png');
			  }
			  
			});
		});
		
		
		/**
		* 设置已经选中的用户
		*/
	 function setSelectedUser(){
	  	var v = W.document.getElementById("addcorp").value;
		var ids = v.split(",");
		$('[name=ids]:checkbox').each(function() {
			for(j=0;j<ids.length;j++){
		   		if($(this).val() == ids[j]){
		   			$(this).attr('disabled',true);
		   			$(this).attr('checked',true);
		   		}
	   		}
		});
	}			
		
	
	</script>
	<script type="text/javascript">
		$(function(){
			initSelArray('cUnit:1','cDept:1','cMinType:2');
			var cCounty = '${cCounty}';
			var cUnit = '${cUnit}';
			var cDept = '${cDept}';
			if(null!=cCounty && cCounty!=""){
				changeCounty(cCounty);
			}
	   		if(cUnit!=null && cUnit!=""){
	   			changeUnit(cUnit);
	   			selected('cUnit',cUnit);	//加载选中项
	   		}
	   		if(cDept!=null && cDept!=""){
	   			selected('cDept',cDept);	//加载选中项
	   		}
	   		
	   		var cMaxType = '${cMaxType}';
			var cMinType = '${cMinType}';
			if(null!=cMaxType && cMaxType!=""){
				changeType(cMaxType);
			}
			if(cMinType!=null && cMinType!=""){
	   			selected('cMinType',cMinType);	//加载选中项
	   		}
	   		
		});
		
		function changeCounty(cid){
	   		var urls='<%=basePath%>/util/data_getDept.action?cUnit='+cid+"&cCounty=1";
	   		buildSelect(cid, 'cUnit',urls,'1');
	   	}
	   	function changeUnit(uid){
	   		var urls="<%=basePath%>/util/data_getDept.action?cUnit="+uid;
	   		buildSelect(uid, 'cDept',urls,'1');
	   	}
	   	function changeType(maxid){
	   		var urls="<%=basePath%>/util/data_getCorpType.action?cMaxType="+maxid;
	   		buildSelect(maxid, 'cMinType',urls,'2');
	   	}
	   	function reSearch(){
	   		window.location.href='<%=basePath%>/oa/notice_corpList.action?search=1';
	   	}
	   	
   		function opdlg(cid){
		   	$.dialog({id:'corpDele',title:'关闭企业',lock:true,width:540,height:300,max: false,min: false,content: 'url:<%=path%>/enterprise/corp_delete.action?corpId='+cid+'',
			   	cancelVal: '关闭',
			   	cancel: true /*为true等价于function(){}*/
			});
		}
		
		function update(id){
			document.form1.corpId.value=id;
			document.form1.submit();
		}
	</script>
  </head>
  
  <body>
	<div  class="body-box">
		<div id="container">
			<fieldset class="serarch_set">
				<legend>
			  		<div class="search">查询条件</div>
			  	</legend>
			  	<form action="<%=basePath%>/oa/notice_corpList.action?search=1" method="post" name="corpForm">
			   		<label style="width: 80px;">属地：</label> 
			   			<s:select list="sdList" name="cCounty" listKey="id" listValue="deptName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;" id="cCounty" onchange="changeCounty(this.value);"></s:select>
			   			<s:select list="#{}" name="cUnit" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="cUnit" onchange="changeUnit(this.value);"></s:select>
			   			<s:select list="#{}" name="cDept" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="cDept"></s:select>
			   		<label style="width: 80px;margin-left:43px;">行业部门：</label><s:select list="hyList" name="cHy" value="%{cHy}" listKey="id" listValue="deptName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;"></s:select>
			   		<br/>
			   		<label style="width: 80px;">企业类型：</label> 
			   			<s:select list="typeList" name="cMaxType" listKey="id" listValue="typeName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;" id="cMaxType" onchange="changeType(this.value);"></s:select> 
			   			<s:select list="#{}" name="cMinType" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="cMinType"></s:select>
			   		<label style="width: 100px;margin-left:180px;">自查上报类型：</label>
			   			<s:select list="#{0:'半月报',1:'月报'}" name="cZcType" listKey="key" listValue="value" value="%{cZcType}" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;"></s:select>
			   		<br/>
			   		<label style="width: 80px;">名称：</label><input type="text" name="keyWord" value="${keyWord }" size="50%">
			   		<input type="submit" value="搜 索" class="link_input" name="btnsx">
			   		<input type="button" value="重置搜索条件" class="link_input" name="btnsx" onclick="reSearch();">
			  	</form>
			</fieldset>
		  	<table border="0" cellpadding="0" cellspacing="0" class="mytable">
		   		<thead>
			    	<tr class="fixedHeaderTr">
			    		<th width="5%">选择</th>
			     		<th width="5%">序号</th>
			     		<th width="20%">企业名称</th>
			     		<th width="20%">属地</th>
			     		<th width="20%">企业类型</th>
			     		<th width="10%">行业部门</th>
			     		<th width="10%" title="企业自查自报上报类型">自查类型</th>
			    	</tr>
		   		</thead>
			   	<tbody>
			   		<s:if test="%{corpList.size>0}">
			   			<s:iterator value="corpList" id="obj" status="x">
				   			<tr>
					     		<td align="center">
					    			<input type="checkbox" name="ids" value="${obj.id }"/> 
					    			<input type="hidden" id="${obj.id }" value="${obj.corpName }"/>
					    		</td>
					     		<td align="center">${x.index+1+(page.num-1)*page.size}</td>
					     		<td align="left"><a href="" target="_blank" title="${obj.corpName}">${obj.corpName }</a></td>
					     		<td align="left">${obj.countyName}-${obj.unitName }-${obj.deptName}</td>
					     		<td align="left">${obj.maxTypeName }-${obj.minTypeName }</td>
					     		<td align="left">${obj.deptMainName }</td>
					     		<td align="center">
					     			<s:if test="%{#obj.reportType==1}">月报</s:if>
					     			<s:if test="%{#obj.reportType==0}">半月报</s:if>
					     		</td>
					    	</tr>
			   			</s:iterator>
			    	</s:if>
			    	<s:else>
				    	<tr>
				     		<td align="center" colspan="7">暂无数据</td>
				    	</tr>
			    	</s:else>
			   	</tbody>
		  	</table>
		  	<div class="btn_page">
		  		<input type="button" id="all" value=" 全 选 " class="link_input">
				<input type="button" id="rev" value=" 反 选 " class="link_input">
				<input type="button" id="empty" value=" 清 空 " class="link_input">
				<input type="button" id="select" value=" 选 择 " class="link_input">
		  	</div>
		  	<div class="page">
				<jsp:include flush="true" page="../share/fenye.jsp">
				    <jsp:param name="url4page" value="/oa/notice_corpList.action?${urls }" />
			    </jsp:include>	    	
		    </div>
	 	</div>
	</div>
	<form action="<%=basePath %>/enterprise/corp_update.action" name="form1" method="post">
		<input type="hidden" name="corpId" value="">
		<input type="hidden" name="urls" value="${urls }">
		<input type="hidden" name="num" value="${page.num }">
		<input type="hidden" name="size" value="${page.size }">
	</form>
  </body>
  <s:if test="%{tip!=null}">
    	<script>
    		alert('${tip}');
    	</script>
    </s:if>
</html>
